package com.boe.common.util.freemark.base;

import lombok.*;
import com.boe.common.util.freemark.BaseMethodModelFreemarker;
import freemarker.template.TemplateModelException;

import java.util.List;
import java.util.stream.Collectors;


public class FreemarkerIsIn extends BaseMethodModelFreemarker {
    @Override
    public Object exec(List list) throws TemplateModelException {
        var paramValue = getFreemarkerParameter(list.get(0));

        var list2 = (List) list.stream().skip(1).map(it -> getFreemarkerParameter(it)).collect(Collectors.toList());

        return list2.contains(paramValue);
    }
}
